﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:vme="clr-namespace:Notoric.ViewModel.Elements.CWNotation;assembly=ViewModel"
                    xmlns:ctrls="clr-namespace:Notoric.View.Music.CWNotation.Controls"
                    xmlns:cvrs="clr-namespace:Notoric.View.Music.CWNotation.Converters">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Barline.xaml"/>
        <ResourceDictionary>
            <DataTemplate DataType="{x:Type vme:DynamicMark}">
                <ctrls:DynamicMark DataContext="{Binding}"/>
            </DataTemplate>
            
            <DataTemplate DataType="{x:Type vme:DynamicsProgressMark}">
                <ctrls:DynamicsProgressMark DataContext="{Binding}"/>
            </DataTemplate>
            
            <DataTemplate DataType="{x:Type vme:Arc}">
                <ctrls:Arc DataContext="{Binding}"/>
            </DataTemplate>
            
            <DataTemplate DataType="{x:Type vme:TimeSignature}">
                <ctrls:TimeSignature DataContext="{Binding}"/>
            </DataTemplate>
            
            <DataTemplate DataType="{x:Type vme:StaffLine}">
                <Line X1="{Binding Path=X1, Mode=OneWay}" X2="{Binding Path=X2, Mode=OneWay}" 
                      Y1="{Binding Path=Y1, Mode=OneWay}" Y2="{Binding Path=Y2, Mode=OneWay}" 
                      Stroke="{Binding Stroke, Mode=OneWay}" StrokeThickness="0.02cm"/>
            </DataTemplate>

            <DataTemplate DataType="{x:Type vme:Clef}">
                <Canvas>
                    <ctrls:Clef DataContext="{Binding}"/>
                </Canvas>
            </DataTemplate>
            
            <DataTemplate DataType="{x:Type vme:KeySignature}">
                <Canvas>
                    <ctrls:KeySignature DataContext="{Binding}"/>
                </Canvas>
            </DataTemplate>
            
            <DataTemplate DataType="{x:Type vme:Rest}">
                <Canvas>
                    <ctrls:Rest DataContext="{Binding}"/>
                </Canvas>
            </DataTemplate>
            
            <DataTemplate DataType="{x:Type vme:Chord}">
                <Canvas>
                    <ctrls:Chord DataContext="{Binding}"/>
                </Canvas>
            </DataTemplate>
            
            <DataTemplate DataType="{x:Type vme:Beam}">
                <Canvas>
                    <ctrls:Beam DataContext="{Binding}"/>
                </Canvas>
            </DataTemplate>
            
            <DataTemplate DataType="{x:Type vme:Staff}">
                <Canvas>
                    <ItemsControl ItemsSource="{Binding Path=Lines, Mode=OneWay}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <Canvas Background="Transparent"/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>
                    <ItemsControl ItemsSource="{Binding Path=Symbols, Mode=OneWay}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <Canvas Background="Transparent"/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>
                    <ItemsControl ItemsSource="{Binding Path=Attachments, Mode=OneWay}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <Canvas Background="Transparent"/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>
                </Canvas>
            </DataTemplate>
            
            <DataTemplate DataType="{x:Type vme:Brace}">
                <Canvas>
                    <!-- TOP BRACE HALF -->
                    <Path Stroke="Black" StrokeThickness="1" Fill="Black">
                        <Path.Data>
                            <PathGeometry>
                                <PathGeometry.Figures>
                                    <PathFigureCollection>
                                        <PathFigure StartPoint="{Binding StartPoint, Mode=OneWay}">
                                            <BezierSegment Point1="{Binding UpperControlPoint1, Mode=OneWay}"
                                                       Point2="{Binding LowerControlPoint1, Mode=OneWay}"
                                                       Point3="{Binding CentralPoint, Mode=OneWay}"
                                                       />
                                        </PathFigure>
                                        <PathFigure StartPoint="{Binding StartPoint, Mode=OneWay}">
                                            <BezierSegment Point1="{Binding UpperControlPoint2, Mode=OneWay}"
                                                       Point2="{Binding LowerControlPoint2, Mode=OneWay}"
                                                       Point3="{Binding CentralPoint, Mode=OneWay}"
                                                       />
                                        </PathFigure>
                                    </PathFigureCollection>
                                </PathGeometry.Figures>
                            </PathGeometry>
                        </Path.Data>
                    </Path>

                    <!-- BOTTOM BRACE HALF -->
                    <Path Stroke="Black" StrokeThickness="1" Fill="Black">
                        <Path.RenderTransform>
                            <ScaleTransform CenterX="{Binding CentralPoint.X, Mode=OneWay}" CenterY="{Binding CentralPoint.Y, Mode=OneWay}"
                                            ScaleX="1" ScaleY="-1"/>
                        </Path.RenderTransform>
                        <Path.Data>
                            <PathGeometry>
                                <PathGeometry.Figures>
                                    <PathFigureCollection>
                                        <PathFigure StartPoint="{Binding StartPoint, Mode=OneWay}">
                                            <BezierSegment Point1="{Binding UpperControlPoint1, Mode=OneWay}"
                                                       Point2="{Binding LowerControlPoint1, Mode=OneWay}"
                                                       Point3="{Binding CentralPoint, Mode=OneWay}"
                                                       />
                                        </PathFigure>
                                        <PathFigure StartPoint="{Binding StartPoint, Mode=OneWay}">
                                            <BezierSegment Point1="{Binding UpperControlPoint2, Mode=OneWay}"
                                                       Point2="{Binding LowerControlPoint2, Mode=OneWay}"
                                                       Point3="{Binding CentralPoint, Mode=OneWay}"
                                                       />
                                        </PathFigure>
                                    </PathFigureCollection>
                                </PathGeometry.Figures>
                            </PathGeometry>
                        </Path.Data>
                    </Path>
                </Canvas>
            </DataTemplate>

            <DataTemplate DataType="{x:Type vme:System}">
                <Canvas>
                    <ItemsControl ItemsSource="{Binding Path=Staves, Mode=OneWay}"/>
                    <ItemsControl ItemsSource="{Binding Path=Barlines, Mode=OneWay}"/>
                    <ItemsControl ItemsSource="{Binding Path=StaffConnectors, Mode=OneWay}"/>
                    <ItemsControl ItemsSource="{Binding Path=Connectors, Mode=OneWay}"/>
                </Canvas>
            </DataTemplate>

            <DataTemplate DataType="{x:Type vme:MusicSectionInterior}">
                <ctrls:MusicSectionInterior DataContext="{Binding}"/>
            </DataTemplate>
        </ResourceDictionary>
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>